<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css"/>
    <script type="text/javascript" src="../../js/itnetcao.js"></script>
    <script type="text/javascript" src="../../js/jquery-2.2.3.min.js"></script>
    <link href="../../js/layui/css/layui.css" rel="stylesheet" />
    
		<title>community</title>
		<style type="text/css">
			*{
				margin: 0;padding: 0;
			}
	      body{
	        font-family:"微软雅黑";
	      }
			.body{
				width: 100%;
				height: 16rem;
			}
			.head{
				font-size: 0.5rem;
				width: 100%;
				height:6rem;
				line-height: 2.2rem;
				background-color: #FFB800;
			}
			a{
				text-decoration: none;
				color: black;
			}
			.head p{
				position: relative;
				left: 3.9rem;
			}
			.head span{
			    position: relative;
				left: -3.5rem;
				top: 0.1rem;
				color: black;
			}
			.head-left{
				height: 3rem;
				width: 3.36rem;
			}
			.head-left img{
				width: 2rem;
				height: 2rem;
				border-radius: 1rem;
				top: -0.6rem;
				position: relative;
				left: 0.6rem;
			}
			.head-left p{
				color: white;
				background-color: mediumorchid;
				font-size: 0.33rem;
				height: 0.6rem;
				line-height: 0.58rem;
				text-align: center;
				width: 1.3rem;
				position: relative;
				left: 1rem;
				top: -0.4rem;
			}
			.head-mid h3{
				position: relative;
				font-size: 0.6rem;
				top:-3.5rem;
				left: 3.4rem;
			}
			.head-mid p{
				position: relative;
				font-size: 0.35rem;
				top: -4.3rem;
				left: 3.4rem;
			}
			.head-mid p:nth-child(3){
				position: relative;
				font-size: 0.35rem;
				top: -6.3rem;
				left: 3.4rem;
			}
			#detail{
				text-decoration: none;
				color: white;
				position: relative;
				padding: 0.2rem 1rem 0.2rem 0.6rem;
				top: -8rem;
				left: 8.2rem;
				background-color: #00BFFF;
				font-size: 0.45rem;
				border-radius: 0.5rem;
			}
			.info{
				margin-top: 0.15rem;
				width: 100%;
				height: 4rem;
				box-shadow: 2px 2px 10px rgba(96,96,96,0.3);
			}
			.info img{
				width: 1.5rem;
				height: 1.5rem;
				border-radius: 0.75rem;
				position: relative;
				left: 0.5rem;
				top: 1rem;
			}
			.info table{
				position: relative;
				left: 3rem;
				font-weight: bold;
			}
			.info td:nth-of-type(odd){
				color: #999999;
			}
		</style>
	</head>
	<body>
		<div class="body" style='overflow:hidden;'>
			<div class="head">
				<p><a href="javascript:history.go(-1)"><span class="glyphicon glyphicon-menu-left"></a></span>
					社区
				</p>
				<div class="head-left">
					<img src="../../image/5.jpg" />
					<p>成员</p>
				</div>
				<div class="head-mid">
					<h3 class='coIphone'>用户名</h3>
					<p>开采人数：<label class='coCount'></label></p>
					<p style='margin-top:0.2rem;'>直推人数：<label class='zhituiCount'></label></p>
				</div>
				<a id="detail" href="detail.html">详情</a>
			</div>
			<div class="info body_data">
					<img src="../../image/5.jpg"/>
					<table>
							<tr>
								<td>手机号：</td>
								<td class='coIphone'></td>
							</tr>
							<tr>
								<td>开采人数：</td>
								<td class='coCount'></td>
							</tr>
							<tr>
								<td>注册日期：</td>
								<td class='coDate'></td>
							</tr>
						</table>
			</div>
			<button style='width:100%;margin-top:100px;' class='layui-btn layui-btn-danger quitComm'>退出</button>
			
			
			<div style='display:none;margin-top:20px;' class='iphoneFindData'>
				<div class="layui-fluid layui-form layui-form-pane loadDate">
				
					<div class="layui-row layui-col-space15">
						<div class="layui-form-item">
							<label class="layui-form-label">手机号码</label>
							<div class="layui-input-inline">
								<input type='text' class='layui-input goFind' placeholder="手机号搜索"/>
							</div>
						</div>
					</div>
				</div>
				<style type='text/css'>
				.dataLoads ul li{
					height:30px;
					line-height:30px;
					
				}
				.dataLoads{
					width:100%;
				}
				</style>
				<div class='dataLoads' style='margin:30px;'>
					<input type='hidden' name='find_comm_qr_code' value='' />
					<ul>
						<li>手机:<span class='find_iphone'></span></li>
						<li>名称:<span class='find_name'></span></li>
						<li>宣言:<span class='find_xuanshi'></span></li>
						<li>时间:<span class='find_shijian'></span></li>
					</ul>
				</div>
				<div>
					<button style='width:100%' class='layui-btn layui-btn-warm addComm'>加入</button>
				</div>
			</div>
			
		</div>
		
		
		
		
		
		
		
	</body>
	<script>
	var userId = jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userId;
	$(function() {
		
		$(".goFind").keyup(function(e) {
			if(e.keyCode == 13) {
				find();
			}
		})
		
		$(".goFind").blur(function() {
			find();
		})
		
		$(".addComm").click(function() {
			var userId = jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userId;
			var url = localStorage.getItem("url") + "/user/controller/UserJoinCommunityAPP.do";
			var data = "userId=" + userId + "&qrCode=" + $("input[name='find_comm_qr_code']").val();
			itcao.itGetAjaxBigData(url, data).done(function(result) {
				var json = jQuery.parseJSON(result);
				if(json.state == true) {
					alert("成功加入");
					window.location.href="community.html";
				}else {
					alert(json.value);
				}
			})
		})
		
		$(".quitComm").click(function() {
			if(confirm("您确定退出该社团?")) {
				/*var userId = jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userId;
				var url = localStorage.getItem("url") + "/user/controller/UserQuitCommunityAPP.do";
				var data = "userId=" + userId;
				itcao.itGetAjaxBigData(url, data).done(function(result) {
					
				})*/
			}
		})
		
		function find() {
			var userId = jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userId;
			var url = localStorage.getItem("url") + "/user/controller/UserFindIphoneCreateCommunityAPP.do";
			var data = "iphone=" + $(".goFind").val();
			itcao.itGetAjaxBigData(url, data).done(function(result) {
				
				var json = jQuery.parseJSON(result);
				
				if(json.state == true) {
					$(".find_iphone").text($(".goFind").val());
					$(".find_name").text(json.bean.coName);
					$(".find_xuanshi").text(json.bean.coContext);
					$(".find_shijian").text(json.bean.coDate);
					$("input[name='find_comm_qr_code']").val(json.bean.coQrCode);
				}else {
					alert("您查找的用户手机还没有创建社团.");
				}
				
			})
			
		}
		
		var url = localStorage.getItem("url") + "/user/controller/UserFindUserIdCreateCommunityAPP.do";
		var data = "userId=" + userId;
		itcao.itGetAjaxBigData(url, data).done(function(result) {
			var json = jQuery.parseJSON(result);
			if(json.state == true) {
				
				$(".coIphone").text(jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userIphone);
				$(".coDate").text(json.bean.coDate);
				
				// 获取社区下总人数
				var url = localStorage.getItem("url") + "/user/controller/UserFindCommunityCountApp.do";
				var data = "coQrCode=" + json.bean.coQrCode;
				itcao.itGetAjaxBigData(url, data).done(function(_result) {
					var ja = jQuery.parseJSON(_result);
					
					url = localStorage.getItem("url") + "/user/controller/UserFindDirectNumberAPP.do";
					data = "userId=" + jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userId;
					
					itcao.itGetAjaxBigData(url, data).done(function(k_result) {
						var jb = jQuery.parseJSON(k_result);
						
						$(".zhituiCount").text(jb.bean);
						
						$(".coCount").text(parseInt(ja.bean) + parseInt(jb.bean));
					})
					
					
				})
				
				
			}else {
					
				var userId = jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userId;
				var url = localStorage.getItem("url") + "/user/controller/UserFindUUIDCreateCommunityAPP.do";
				var data = "userId=" + userId;
				itcao.itGetAjaxBigData(url, data).done(function(result) {
					var json = jQuery.parseJSON(result);
					if(json.state == true) {
						$(".coIphone").text(jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userIphone);
						$(".coDate").text(json.bean.coDate);
						
						// 获取社区下总人数
						var url = localStorage.getItem("url") + "/user/controller/UserFindCommunityCountApp.do";
						var data = "coQrCode=" + json.bean.coQrCode;
						itcao.itGetAjaxBigData(url, data).done(function(_result) {
							var ja = jQuery.parseJSON(_result);
							if(ja.state == true) {
								$(".coCount").text(ja.bean);
							}
							url = localStorage.getItem("url") + "/user/controller/UserFindDirectNumberAPP.do";
							data = "userId=" + jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userId;
							
							itcao.itGetAjaxBigData(url, data).done(function(k_result) {
								var jb = jQuery.parseJSON(k_result);
								if(jb.state == true) {
									$(".zhituiCount").text(jb.bean);
									$(".coCount").text(parseInt(ja.bean) + parseInt(jb.bean));
								}
							})
						})
						
					}else {
						$(".body_data").hide();
						$(".quitComm").hide();
						$(".iphoneFindData").show();
					}
				})
					
			}
		})
	})
	</script>
	<script>
			(function() {
				var supportsOrientationChange = 'onorientationchange' in window ? 'orientationchange' : 'resize';
				var timeoutId;
				function setRem() {
					var clientWidth = document.documentElement.clientWidth;
					var nowPX = clientWidth / 1024 * 100;
					document.documentElement.style.fontSize = nowPX + 'px';
				}
				setRem();
				window.addEventListener(supportsOrientationChange, function() {
					clearTimeout(timeoutId);
					timeoutId = setTimeout(function() {
						setRem();
					}, 300);
				}, false);
			})();
		</script>
</html>
